<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <link rel="stylesheet" th:href="@{/static/element/index.css}"/>
</head>
<body>
<div id="app">
    <template>
        <el-form :model="importsForm" ref="importsForm" label-width="100px">
            <el-row>
                <el-col :span="7">
                    <el-form-item label="用户表格" prop="avatar">
                        <el-upload class="avatar-uploader" :action="uploadUrl" :headers="uploadHeaders" :show-file-list="false"
                                   :on-success="handleAvatarSuccess.bind(this,'head')">
                            <el-avatar v-if="importsForm.avatar" :src="importsForm.avatar"></el-avatar>
                            <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                        </el-upload>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <div style="text-align: center;">
            <el-button @click="closePage">取 消</el-button>
        </div>
    </template>
</div>
</body>
<script th:src="@{/static/js/axios.min.js}"></script>
<script th:src="@{/static/js/request.js}"></script>
<script th:src="@{/static/js/common.js}"></script>
<script th:src="@{/static/js/vue.min.js}"></script>
<script th:src="@{/static/element/index.js}"></script>
<script th:src="@{/static/js/jquery.min.js}"></script>
<script th:src="@{/static/layer/layer.js}"></script>
<script>
    new Vue({
        el: '#app',
        data() {
			return {
                uploadUrl: '/sys/user/imports',
                uploadHeaders: {"token": JSON.parse(localStorage.getItem("mars-token"))},
                importsForm: {
                    avatar: ''
                }
			}
        },
        methods: {
            handleAvatarSuccess(idx, res, file, name) {
                if (res.code === '200') {
                    parent.layer.msg('导入成功');
                    closePage();
                } else {
                    parent.layer.msg(res.message);
                }
            }
        }
    });
</script>
</html>
